<%@page import="jobportal.Dbconn"%>
<%@page import="javax.imageio.ImageIO"%>
<%@page import="java.awt.image.BufferedImage"%>

<%@ page import="java.sql.*,java.io.*" %>
<%
    Connection con=null;
    Statement st=null;
    ResultSet rs=null;
    if ( request.getParameter("id") != null ){
        String id = request.getParameter("id");
        String table = request.getParameter("table");
        String col = request.getParameter("col");
        String pk_col = request.getParameter("pk_col");
        String sql="Select "+col+" From "+table+" Where "+pk_col+" = '" +id+"' and " +col+" is not null";
        try {
            con=Dbconn.getConn();
            st=con.createStatement();
	    Blob img;
            
            rs=st.executeQuery(sql);
            byte[] imgData=new byte[10000];
            if (rs.next ()){
                img = rs.getBlob(1);
                imgData = img.getBytes(1,(int)img.length());

            
                response.setContentType( "application/msword" );
                response.setHeader("Content-Disposition","attachment; filename=\""+"resume.doc"+"\"");
response.setHeader("cache-control", "no-cache");


ServletOutputStream outs = response.getOutputStream();
outs.write(imgData);
outs.flush();
outs.close();
            }
            else{
               // response.sendRedirect("../uploadResume.jsp?status=No Resume Exist");
                out.println("No Resume Exist");

        }}
        catch (Exception e){
            out.println("Exception::"+e);
        }
    }
    else
        out.println("Invalid Data");
%>
